home *** CD-ROM | disk | FTP | other *** search
- class Citizen extends smashing.Renderable
- {
- var update;
- var myFloor;
- var m;
- var oBuildings;
- var x;
- var y;
- var oCitizenHandler;
- var r = 15;
- var sType = "citizen";
- var bounce = 500;
- var bDead = true;
- var nDie = 2;
- var cDie = 0;
- function Citizen()
- {
- super();
- this.update = this.updateNormal;
- this.myFloor = BuildingHandler.floor - this.r - 50;
- }
- function updateNormal(nElapsed)
- {
- this.m.y += smashing.Phys.gr * nElapsed;
- var _loc10_ = this.oBuildings.oHandler.clips;
- var _loc11_ = _loc10_.length;
- var _loc7_ = undefined;
- var _loc6_ = undefined;
- var _loc3_ = undefined;
- var _loc8_ = undefined;
- var _loc9_ = new smashing.Point(this.x,this.y);
- var _loc4_ = new smashing.Point(this.m.x * nElapsed,this.m.y * nElapsed);
- if(this.y + _loc4_.y > this.myFloor)
- {
- this.m.x = 0;
- this.m.y = 0;
- this.x += _loc4_.x;
- this.y = this.myFloor;
- _loc4_.x = 0;
- _loc4_.y = 0;
- this.bDead = false;
- this.update = this.updateDizzy;
- this.gotoAndStop("land");
- }
- else
- {
- var _loc5_ = 0;
- while(_loc5_ < _loc11_)
- {
- _loc7_ = _loc10_[_loc5_];
- if(_loc7_.hitTest(this) == true)
- {
- _loc6_ = _loc7_.aLines;
- _loc8_ = _loc6_.length;
- var _loc2_ = 0;
- while(_loc2_ < _loc8_)
- {
- _loc3_ = _loc6_[_loc2_].collisionPointSwept(_loc9_,_loc4_,this.r);
- if(_loc3_ != null)
- {
- this.m.x = 0;
- this.m.y = 0;
- _loc4_.x = 0;
- _loc4_.y = 0;
- this.x = _loc3_.hit.x;
- this.y = _loc3_.hit.y;
- this.bDead = false;
- this.update = this.updateDizzy;
- this.gotoAndStop("land");
- break;
- }
- _loc2_ = _loc2_ + 1;
- }
- }
- _loc5_ = _loc5_ + 1;
- }
- }
- this.x += _loc4_.x;
- this.y += _loc4_.y;
- }
- function updateDizzy(nElapsed)
- {
- }
- function updateHit(nElapsed)
- {
- this.m.y += smashing.Phys.gr * nElapsed;
- this.x += this.m.x * nElapsed;
- this.y += this.m.y * nElapsed;
- }
- function render()
- {
- var _loc2_ = smashing.Viewport.getPos(this);
- if(Math.abs(_loc2_.x) > smashing.Viewport.halfWidth + this.r)
- {
- this.oCitizenHandler.removeCitizen(this);
- }
- this._x = _loc2_.x + smashing.Viewport.centerX;
- this._y = _loc2_.y + smashing.Viewport.centerY;
- }
- function collisionTest(oPlayer)
- {
- var _loc2_ = new smashing.Point(oPlayer.x - this.x,oPlayer.y - this.y);
- var _loc4_ = _loc2_.y;
- _loc2_.y += oPlayer.r * oPlayer.nCrouchMod * (_loc4_ / Math.abs(_loc4_));
- var _loc5_ = Math.pow(this.r + oPlayer.r,2);
- if(_loc2_.dot(_loc2_) < _loc5_)
- {
- return true;
- }
- return false;
- }
- function react(oPlayer, nElapsed)
- {
- oPlayer.hurt();
- this.m = new smashing.Point(1,-1);
- this.m.length = this.bounce;
- this.bDead = true;
- this.update = this.updateHit;
- }
- }
-